from cfg import *
'''定义按钮'''
import pygame


def Button( screen, position, text, button_size=(200, 50)):
    left, top = position
    bwidth, bheight = button_size
    pygame.draw.line(screen, (150, 150, 150), (left, top), (left + bwidth, top), 5)
    pygame.draw.line(screen, (150, 150, 150), (left, top - 2), (left, top + bheight), 5)
    pygame.draw.line(screen, (50, 50, 50), (left, top + bheight), (left + bwidth, top + bheight), 5)
    pygame.draw.line(screen, (50, 50, 50), (left + bwidth, top + bheight), (left + bwidth, top), 5)
    pygame.draw.rect(screen, (100, 100, 100), (left, top, bwidth, bheight))
    font = pygame.font.SysFont(font_name, 30, True)
    text_render = font.render(text, 1, (255, 235, 205))
    return screen.blit(text_render, (left + 50, top + 10))

def drawText(msg, color, pot, screen):
    screen.blit(pygame.font.SysFont("SimHei", 36, True).render(msg, True, color), pot)

def gameBgImg(screen, img, angle, bg_size=(720,1280)):
    # 缩放图片
    bgImg = pygame.transform.scale(pygame.transform.rotate(img, angle), bg_size)
    image_width, image_height = bgImg.get_size()
    screen_width, screen_height = bg_size
    image_x = (screen_width - image_width) // 2
    image_y = (screen_height - image_height) // 2
    screen.blit(bgImg, (image_x, image_y))

def playMyBgMusic(uri):
    pygame.mixer.music.load(uri)
    pygame.mixer.music.play(-1)